/**
    给定一个仅包含数字 2-9 的字符串，返回所有它能表示的字母组合。

    给出数字到字母的映射如下（与电话按键相同）。注意 1 不对应任何字母。

    示例:

    输入："23"
    输出：["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
 * @param {string} digits
 * @return {string[]}
 */
var letterCombinations = function (digits) {
    const map = {
        '0': '',
        '1': '',
        '2': 'abc',
        '3': 'def',
        '4': 'ghi',
        '5': 'jkl',
        '6': 'mno',
        '7': 'pqrs',
        '8': 'tuv',
        '9': 'wxyz'
    }
    const result = [];
    function create(index = 0, prefix = '') {
        if(index == digits.length) {
            result.push(prefix);
            return;
        }
        if(digits[index] == '0' || digits[index] == '1') {
            create(index++, prefix);
        }
        let str = map[digits[index]];
        index++;
        for(let char of str) {
            create(index, prefix+char);
        }
    }
    create();
    return result;
};
function run () {
    ['ab','ac','ad','bb','bc','bd','cb','cc','cd']
    ["ad","ae","af","bd","be","bf","cd","ce","cf"] // expect
    let args = [
        "23"
    ];
    return letterCombinations(...args);
}
module.exports = run;